//  获取爆款文案库 需要的时间函数
// const now = new Date('2024-06-05T15:16:17');  // 假设当前时间为 2024-06-05 15:16:17
// const oneDayBefore = getPreviousDates(now, 1);
// const threeDaysBefore = getPreviousDates(now, 3);
// const sevenDaysBefore = getPreviousDates(now, 7);
function getFormattedDate(date) {
    const year = date.getFullYear();
    const month = String(date.getMonth() + 1).padStart(2, '0');
    const day = String(date.getDate()).padStart(2, '0');
    return `${year}-${month}-${day}`;
}


export function getPreviousDates(referenceDate, days) {
    const date = new Date(referenceDate);
    date.setDate(date.getDate() - days);
    return getFormattedDate(date);
}


// 获取互动总数
export const formatSum = (numbers) => {
    const sum = numbers.reduce((acc, num) => acc + num, 0);
    if (sum < 10000) {
        return sum.toString();
    } else {
        // 注意：这里的单位是 "W"，表示万
        // 389.61W 是一个示例，可以根据实际的算法调整
        const formattedSum = (sum / 10000).toFixed(2);
        return `${formattedSum}W`;
    }
}